//
//  FZJSExportObject.m
//  EnglishTalk
//
//  Created by 周咏 on 15/11/19.
//  Copyright © 2015年 Feizhu Tech. All rights reserved.
//

#import "FZJSExportObject.h"
//#import "NSString+FZNumber.h"
#import "SRCommonConstants.h"

@implementation FZJSExportObject

-(void)test{
    NSLog(@"test");
}

-(void)jsCallback:(NSString *)jsonObject{
    
    if(!jsonObject || [jsonObject isEqualToString:@""]){
        return;
    }
    
    NSError *error;
    NSDictionary *json = [NSJSONSerialization JSONObjectWithData:[jsonObject  dataUsingEncoding:NSUTF8StringEncoding]options:kNilOptions error:&error];
    if (json == nil) {
        return;
    }
    
    NSString *action = [json objectForKey:@"action"];
    NSString *actionName = [json objectForKey:@"actionName"];
    NSDictionary *params = [json objectForKey:@"params"];
    NSString *refresh = [json objectForKey:@"refresh"];
//    NSLog(@"FZJSExportObject: %@  ", json);
    
    if ([refresh integerValue]==1) {
        [[NSNotificationCenter defaultCenter]postNotificationName: @"needRefresh" object:nil];
    } else if([action intValue] == 2){
//        //方法调用
//        //发送通知
//        [[NSNotificationCenter defaultCenter] postNotificationName:FZJSExportCallBackMethodNotification object:actionName userInfo:params];
//    }else if([action intValue] == 2){
//        //controller跳转
//        dispatch_async(dispatch_get_main_queue(), ^{
//            CellPhoneViewController*controller=[[CellPhoneViewController alloc]init];
//            controller.hideCustomNavigationView = YES;
//            AppDelegate *appdelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
//            [appdelegate.tabBarController.selectedViewController pushViewController:controller animated:YES];
//
//        });
    } else {
        if(self.callBackDelegate && [self.callBackDelegate respondsToSelector:@selector(jsCallback:params:)]){
            [self.callBackDelegate jsCallback:[action intValue] params:json];
        }
    }

}

@end
